package com.lanqiao.gxnushop.mapper;

import com.lanqiao.gxnushop.entity.Glance;
import io.swagger.v3.oas.annotations.media.Schema;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

@Mapper
@Schema(description ="用户浏览表")
public interface GlanceMapper {
    @Schema(description ="添加浏览记录")
    @Insert("insert into glance(glanceId,buyerId,productId,collect) values (#{glanceId},#{buyerId},#{productId},#{collect})")
    boolean add(Glance glance);

    @Schema(description ="删除浏览记录")
    @Delete("delete from glance where glanceId=#{glanceId}")
    boolean delete(String glanceId);

    @Schema(description ="根据买家id查询浏览记录")
    @Select("select * from glance where buyerId=#{buyerId}")
    ArrayList<Glance> findByBuyerId(String buyerId);

    @Schema(description ="根据浏览记录id查询浏览记录")
    @Select("select * from glance where glanceId=#{glanceId}")
    Glance findById(String glanceId);

    /*@Schema(description ="更新浏览记录")
    @Update("update glance set productId=#{productId} where glanceId=#{glanceId}")
    boolean update(Glance glance);*/

    @Schema(description ="根据买家id和商品id查询浏览记录")
    @Select("select * from glance where buyerId=#{buyerId} AND productId=#{productId}")
    ArrayList<Glance> findByBuyerIdAndProductId(String buyerId, String productId);

    @Schema(description ="根据商品id查询浏览记录")
    @Select("select * from glance where productId=#{productId}")
    ArrayList<Glance> findByProductId(String productId);
}
